import { Router } from 'vue-router'
import { useUserStore } from '@/store'
import { configName } from '@/config'

export const useCheckToken = (router: Router) => {
  router.beforeEach((to) => {
    const userInfo = useUserStore().user
    const token = userInfo?.token
    if (to.name !== configName().LoginName) {
      if (!token) {
        return {
          name: configName().LoginName
        }
      }
    }
  })
}
